package com.wetech.demo.web3j.contracts.iaccount;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.Address;
import org.web3j.abi.datatypes.DynamicBytes;
import org.web3j.abi.datatypes.DynamicStruct;
import org.web3j.abi.datatypes.Function;
import org.web3j.abi.datatypes.Type;
import org.web3j.abi.datatypes.generated.Bytes32;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.RemoteCall;
import org.web3j.protocol.core.RemoteFunctionCall;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.tx.Contract;
import org.web3j.tx.TransactionManager;
import org.web3j.tx.gas.ContractGasProvider;

/**
 * <p>Auto generated code.
 * <p><strong>Do not modify!</strong>
 * <p>Please use the <a href="https://docs.web3j.io/command_line.html">web3j command line tools</a>,
 * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the 
 * <a href="https://github.com/LFDT-web3j/web3j/tree/main/codegen">codegen module</a> to update.
 *
 * <p>Generated with web3j version 4.14.0.
 */
@SuppressWarnings("rawtypes")
public class IAccount extends Contract {
    public static final String BINARY = "";

    private static String librariesLinkedBinary;

    public static final String FUNC_VALIDATEUSEROP = "validateUserOp";

    @Deprecated
    protected IAccount(String contractAddress, Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    protected IAccount(String contractAddress, Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
    }

    @Deprecated
    protected IAccount(String contractAddress, Web3j web3j, TransactionManager transactionManager,
            BigInteger gasPrice, BigInteger gasLimit) {
        super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    protected IAccount(String contractAddress, Web3j web3j, TransactionManager transactionManager,
            ContractGasProvider contractGasProvider) {
        super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public RemoteFunctionCall<TransactionReceipt> validateUserOp(PackedUserOperation userOp,
            byte[] userOpHash, BigInteger missingAccountFunds) {
        final Function function = new Function(
                FUNC_VALIDATEUSEROP, 
                Arrays.<Type>asList(userOp, 
                new org.web3j.abi.datatypes.generated.Bytes32(userOpHash), 
                new org.web3j.abi.datatypes.generated.Uint256(missingAccountFunds)), 
                Collections.<TypeReference<?>>emptyList());
        return executeRemoteCallTransaction(function);
    }

    @Deprecated
    public static IAccount load(String contractAddress, Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        return new IAccount(contractAddress, web3j, credentials, gasPrice, gasLimit);
    }

    @Deprecated
    public static IAccount load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
        return new IAccount(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
    }

    public static IAccount load(String contractAddress, Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        return new IAccount(contractAddress, web3j, credentials, contractGasProvider);
    }

    public static IAccount load(String contractAddress, Web3j web3j,
            TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
        return new IAccount(contractAddress, web3j, transactionManager, contractGasProvider);
    }

    public static RemoteCall<IAccount> deploy(Web3j web3j, Credentials credentials,
            ContractGasProvider contractGasProvider) {
        return deployRemoteCall(IAccount.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<IAccount> deploy(Web3j web3j, Credentials credentials,
            BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(IAccount.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static RemoteCall<IAccount> deploy(Web3j web3j, TransactionManager transactionManager,
            ContractGasProvider contractGasProvider) {
        return deployRemoteCall(IAccount.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), "");
    }

    @Deprecated
    public static RemoteCall<IAccount> deploy(Web3j web3j, TransactionManager transactionManager,
            BigInteger gasPrice, BigInteger gasLimit) {
        return deployRemoteCall(IAccount.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), "");
    }

    public static void linkLibraries(List<Contract.LinkReference> references) {
        librariesLinkedBinary = linkBinaryWithReferences(BINARY, references);
    }

    private static String getDeploymentBinary() {
        if (librariesLinkedBinary != null) {
            return librariesLinkedBinary;
        } else {
            return BINARY;
        }
    }

    public static class PackedUserOperation extends DynamicStruct {
        public String sender;

        public BigInteger nonce;

        public byte[] initCode;

        public byte[] callData;

        public byte[] accountGasLimits;

        public BigInteger preVerificationGas;

        public byte[] gasFees;

        public byte[] paymasterAndData;

        public byte[] signature;

        public PackedUserOperation(String sender, BigInteger nonce, byte[] initCode,
                byte[] callData, byte[] accountGasLimits, BigInteger preVerificationGas,
                byte[] gasFees, byte[] paymasterAndData, byte[] signature) {
            super(new org.web3j.abi.datatypes.Address(160, sender), 
                    new org.web3j.abi.datatypes.generated.Uint256(nonce), 
                    new org.web3j.abi.datatypes.DynamicBytes(initCode), 
                    new org.web3j.abi.datatypes.DynamicBytes(callData), 
                    new org.web3j.abi.datatypes.generated.Bytes32(accountGasLimits), 
                    new org.web3j.abi.datatypes.generated.Uint256(preVerificationGas), 
                    new org.web3j.abi.datatypes.generated.Bytes32(gasFees), 
                    new org.web3j.abi.datatypes.DynamicBytes(paymasterAndData), 
                    new org.web3j.abi.datatypes.DynamicBytes(signature));
            this.sender = sender;
            this.nonce = nonce;
            this.initCode = initCode;
            this.callData = callData;
            this.accountGasLimits = accountGasLimits;
            this.preVerificationGas = preVerificationGas;
            this.gasFees = gasFees;
            this.paymasterAndData = paymasterAndData;
            this.signature = signature;
        }

        public PackedUserOperation(Address sender, Uint256 nonce, DynamicBytes initCode,
                DynamicBytes callData, Bytes32 accountGasLimits, Uint256 preVerificationGas,
                Bytes32 gasFees, DynamicBytes paymasterAndData, DynamicBytes signature) {
            super(sender, nonce, initCode, callData, accountGasLimits, preVerificationGas, gasFees, paymasterAndData, signature);
            this.sender = sender.getValue();
            this.nonce = nonce.getValue();
            this.initCode = initCode.getValue();
            this.callData = callData.getValue();
            this.accountGasLimits = accountGasLimits.getValue();
            this.preVerificationGas = preVerificationGas.getValue();
            this.gasFees = gasFees.getValue();
            this.paymasterAndData = paymasterAndData.getValue();
            this.signature = signature.getValue();
        }
    }
}
